package com.leo.controller;

import com.leo.service.UserInfoService;
import com.leo.util.ApplicationContextUtil;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * @ClassName: GetUserInfoRestfulController
 * @Description: ${description}
 * @Author: leo825
 * @Date: 2020-01-02 17:36
 * @Version: 1.0
 */
public class GetUserInfoStringController implements Controller {

    @Override
    public ModelAndView handleRequest(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception {
        UserInfoService userInfoService = (UserInfoService) ApplicationContextUtil.getBean("userInfoService");
        System.out.println("GetUserInfoStringController获取用户信息");
        List userInfoList = userInfoService.getUserInfoList();
        System.out.println(userInfoList);
        httpServletResponse.setCharacterEncoding("UTF-8");
        httpServletResponse.setContentType("text/html;charset=UTF-8");
        httpServletResponse.getWriter().write(userInfoList.toString());
        return null;
    }
}
